# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgbase=qcoro
pkgname=(qcoro-qt5 qcoro-qt6)
pkgver=0.9.0
pkgrel=1
pkgdesc='C++ Coroutines for Qt'
arch=(loong64 x86_64)
url='https://github.com/danvratil/qcoro'
license=(MIT)
makedepends=(cmake qt5-websockets qt6-websockets qt5-declarative qt6-declarative)
source=(https://github.com/danvratil/qcoro/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('cfaf6b778450f06adac4ce5e353eb6eae213a3b62b8c8740520d58cf9fe3ec1a')

build() {
  cmake -B build5 -S $pkgbase-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DUSE_QT_VERSION=5 \
    -DBUILD_SHARED_LIBS=ON
  cmake --build build5

  cmake -B build6 -S $pkgbase-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DUSE_QT_VERSION=6 \
    -DBUILD_SHARED_LIBS=ON
  cmake --build build6
}

package_qcoro-qt5() {
  depends=(qt5-websockets qt5-declarative)
  DESTDIR="$pkgdir" cmake --install build5
  install -Dm644 $pkgbase-$pkgver/LICENSES/MIT.txt -t "$pkgdir"/usr/share/licenses/$pkgname
}

package_qcoro-qt6() {
  depends=(qt6-websockets qt6-declarative)
  DESTDIR="$pkgdir" cmake --install build6
  install -Dm644 $pkgbase-$pkgver/LICENSES/MIT.txt -t "$pkgdir"/usr/share/licenses/$pkgname
}
